package cn.tedu.medicalappointmentsystemk.dao.persist.repository.impl;

import cn.tedu.medicalappointmentsystemk.dao.persist.mapper.DoctorDepartmentMapper;
import cn.tedu.medicalappointmentsystemk.dao.persist.repository.DoctorDepartmentRepository;
import cn.tedu.medicalappointmentsystemk.pojo.po.DoctorDepartmentPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class DoctorDepartmentRepositoryImpl implements DoctorDepartmentRepository {
    @Autowired
    DoctorDepartmentMapper mapper;
    @Override
    public Integer addNew(DoctorDepartmentPO po) {
        return mapper.insert(po);
    }

    @Override
    public Integer deleteByDoctorId(Long doctorId) {
        QueryWrapper<DoctorDepartmentPO> qw = new QueryWrapper<>();
        qw.eq("doctor_id",doctorId);
        return mapper.delete(qw);
    }

    @Override
    public DoctorDepartmentPO selectByDoctorId(Long doctorId) {
        QueryWrapper<DoctorDepartmentPO> qw = new QueryWrapper<>();
        qw.eq("doctor_id",doctorId);
        return mapper.selectOne(qw);
    }

    @Override
    public Integer deleteByDepartmentId(Long departmentId) {
        QueryWrapper<DoctorDepartmentPO> qw = new QueryWrapper<>();
        qw.eq("department_id",departmentId);
        return mapper.delete(qw);
    }


}
